﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Threading;
using System.Globalization;

public partial class Defaultmaster : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // NavigateUrl= '<%= Session("url").ToString()%>'
        if (!Page.IsPostBack)
        {
            //4853430
            if (Session["user"] != null)
            {

                //logincontainer.Visible = false;
                logout.Visible = true;
                users.Text = Session["user"].ToString().Split(',')[0];

            }
        }
       
        if (Session["user"] != null)
        {
            lk1.PostBackUrl = Session["url"].ToString();
        }

    }
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        Thread.CurrentThread.CurrentUICulture = new CultureInfo("ar-SA");
        Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("ar-SA");
        Thread.CurrentThread.CurrentCulture.DateTimeFormat = new CultureInfo("en-US", false).DateTimeFormat;

        Session["CurrentCulture"] = "ar-SA";
        Server.Transfer(Request.Path);
    }
    protected void LinkButton3_Click(object sender, EventArgs e)
    {
        Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
        Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
        Session["CurrentCulture"] = "en-US";
        Server.Transfer(Request.Path);
    }
    //protected void Button1_Click(object sender, EventArgs e)
    //{
    //    DataTable dr = DB.Authenticate(username.Text, password.Text);

    //    if (dr.Rows.Count > 0)
    //    {

    //        DataRow dt = dr.Rows[0];
    //        string act = dt["active"].ToString();
    //        if (dt["active"].ToString() == "" || Boolean.Parse(dt["active"].ToString()))
    //        {
    //            Session["user"] = dt["username"].ToString() + ","+dt["id"].ToString();
    //            string co = dt["company_id"].ToString();
    //            Session["company_id"] = co;
    //            Session["role_id"] = dt["role_id"].ToString();
    //            Session["CurrentCulture"] = "ar-SA";
    //            DB.UPDATE("mysettings", "int,id,1", "loginintime", "datetime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));//("g", culture));
    //            Session.Add("allsettings", DB.getcurrentssettings());

    //            switch (int.Parse(dt["role_id"].ToString()))
    //            {
    //                case 1:
    //                    Session["url"] = "~/ManagerDefault.aspx";

    //                    Response.Redirect("~/ManagerDefault.aspx");

    //                    break;
    //                case 2:
    //                    //if (Boolean.Parse(dt["active"].ToString()))
    //                    //{
    //                        Session["url"] = "~/companypart/CompanyNotifications.aspx";

    //                        Response.Redirect("~/companypart/CompanyNotifications.aspx");
    //                    //}
    //                    //else
    //                    //{
    //                    //    res.Text = this.GetGlobalResourceObject("Resource", "stop").ToString();

    //                    //}
    //                    break;
    //                case 3:
    //                    //if (Boolean.Parse(dt["active"].ToString()))
    //                    //{
    //                       Session["url"] = "~/followerpart/CompanyNotifications.aspx";

    //                        Response.Redirect("~/followerpart/CompanyNotifications.aspx");
    //                   // }
                        
    //                    break;
    //                default:
    //                    Session["url"] = "~/Default.aspx";
    //                    Response.Redirect("~/Default.aspx");

    //                    break;

    //            }
    //        }
    //        else
    //        {
    //            res.Text = this.GetGlobalResourceObject("Resource", "stop").ToString();

    //        }

           
    //    }
    //    else
    //    {
    //        res.Text = this.GetGlobalResourceObject("Resource", "notcorrect").ToString();
    //    }

    //}
    protected void LinkButton8_Click(object sender, EventArgs e)
    {
        string obj = Session["CurrentCulture"].ToString();

        Session.Clear();
        Session["CurrentCulture"] = obj;
        Thread.CurrentThread.CurrentUICulture = new CultureInfo(obj);
        Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(obj);
        Response.Redirect("~/Default.aspx");
    }
}
